﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using BomberManServer.Gaming.Object.Mapping.Items;
using BomberManServer.Utils;

namespace BomberManServer.Gaming.Object
{
    public class Player
    {
        // int identifying the player in the game
        public UInt32 token { get; private set; }
        // player id in the game from WebService
        public UInt32 uid { get; private set; }
        // player id in the game for the client
        public UInt32 id;
        // player name
        public string name { get; private set; }
        // player bonuses
        public UInt32 speed { get; private set; }
        public UInt32 delay { get; private set; }
        public UInt32 bomb { get; private set; }
        public UInt32 range { get; private set; }
        public Avatar avatar { get; private set; }

        // contructor called by WebService parser
        public Player(UInt32 token, UInt32 uid, string name, UInt32 speed, UInt32 delay, UInt32 bomb, UInt32 range)
        {
            this.token = token;
            this.uid = uid;
            this.name = name;
            this.speed = speed == 0 ? Constants.instance.speed:(speed * Constants.instance.speedCoef + Constants.instance.speed);
            this.delay = delay == 0 ? Constants.instance.bomb_delay:(UInt32)(delay * Constants.instance.delayCoef * Constants.instance.actions_per_second);
            this.bomb = bomb == 0 ? Constants.instance.bomb_max:(bomb + Constants.instance.bomb_max);
            this.range = range == 0 ? Constants.instance.deflag_length:(range + Constants.instance.deflag_length);
            avatar = new Avatar(this);
        }

        // return true is the token is the same
        public bool compareToken(UInt32 token) {
            return (this.token == token);
        }
    }
}
